<template>
  <el-container class="home-container">
    <el-header><!-- 头部区 -->
      <div>
        <span id="fontLogo">智能快递柜后台管理系统</span>
      </div>
      <el-menu
          :default-active="activeIndex"
          class="el-menu-demo"
          mode="horizontal"
          @select="handleSelect"
          background-color="#545c64"
          text-color="#fff"
          active-text-color="#ffd04b"
          id="indexMenu">
        <el-menu-item index="1" @click="shouye">首页</el-menu-item>
        <el-menu-item index="2" @click="expressList">会员</el-menu-item>
        <el-menu-item index="3" @click="goToMachine">柜机</el-menu-item>
        <el-menu-item index="4" @click="baoguo">包裹</el-menu-item>
        <el-menu-item index="5" @click="tiaozhuan">财务</el-menu-item>
        <el-menu-item index="6" @click="other">其他</el-menu-item>
      </el-menu>
      <div>
        <span id="fontName">{{this.name}}</span>
      </div>
    </el-header>
    <!-- 页面主体区域 -->
    <el-container>
      <!-- 侧边栏 -->
      <el-aside width="210px" hight="100%">
        <el-menu
            class="el-menu-vertical-demo"
            background-color="#545c64"
            text-color="#fff"
            active-text-color="#ffd04b">

          <el-menu-item index="2">
            <i class="el-icon-menu"></i>
            <span @click="expressList">快递员列表</span>
          </el-menu-item>
          <el-menu-item index="2">
            <i class="el-icon-menu"></i>
            <span slot="title" @click="expressAuth">快递员认证审核</span>
          </el-menu-item>
          <el-menu-item index="3">
            <i class="el-icon-setting"></i>
            <span slot="title" @click="expressMember">普通会员列表</span>
          </el-menu-item>
        </el-menu>
      </el-aside>
      <!-- 右侧内容主体 -->
      <el-main>
        <div style="margin-left: 20px; margin-top: 20px">
 <span style="color: whitesmoke; text-align: left">
   会员管理/快递员列表/快递员详情
</span>
        <div style="width: 1880px;background-color: whitesmoke; height: 800px">
<!--          上半部分-->
          <div style="width: 100%; height: 40px; border-color: #181818;text-align: left">
            <span style="font-size: 20px; text-align: left;margin-left: 10px;margin-top: 10px">快递员详情</span>
            <div style="margin-left: 1830px" @click="expressList">
              返回
            </div>
          </div>
          <div style="margin-top: 10px;background-color: whitesmoke;height: 250px;width: 100%;display: flex">
            <div style="width: 200px;height: 200px;background-color: antiquewhite;margin-top: 30px;margin-left: 30px">
              <el-image
                  style="width: 200px; height: 200px"
                  :src="form.photo"
                  :fit="fit"></el-image>
            </div>
            <div style="width: 1600px;height: 200px;margin-top: 30px;margin-left: 30px;display: flex">
              <div style="width: 500px;height: 100%;">
                  <div style="width: 100%;height: 65px;text-align: left;font-size: 18px">

                          <span style="margin-left: 20px;margin-top: 20px">真实姓名： {{form.name}}</span>
                  </div>
                <div style="width: 100%;height: 65px;text-align: left;font-size: 18px">
                  <span style="margin-left: 20px;margin-top: 20px">手机号码：  {{form.phone}}</span>
                </div>
                <div style="width: 100%;height: 65px;text-align: left;font-size: 18px">
                  <span style="margin-left: 20px;margin-top: 20px">注册类型：  {{form.registrationType==1 ? '自主注册' : '后台创建'}}</span>
                </div>
              </div>

              <div style="width: 500px;height: 100%;">
                <div style="width: 100%;height: 65px;text-align: left;font-size: 18px"  v-if="form.isVip==1">
                  <span style="margin-left: 20px;margin-top: 20px">快递公司：  {{form.postCompany}}</span>
                </div>
                <div style="width: 100%;height: 65px;text-align: left;font-size: 18px">
                  <span style="margin-left: 20px;margin-top: 20px">实名认证：  {{form.realNameStatus==1 ? '已认证' : '未认证'}}</span>
                </div>
                <div style="width: 100%;height: 65px;text-align: left;font-size: 18px">
                  <span style="margin-left: 20px;margin-top: 20px">会员余额：  {{form.accountBalance}}</span>
                </div>
              </div>

              <div style="width: 500px;height: 100%;">
                <div style="width: 100%;height: 65px;text-align: left;font-size: 18px">
                  <span style="margin-left: 20px;margin-top: 20px">会员状态：{{form.status==1 ? '正常' : '禁用'}}</span>
                  <button style="margin-left: 50px" @click="updateStatusTrue(form.registerIp)" v-if="form.status==2">
                    启用
                  </button>
                  <button style="margin-left: 50px" @click="updateStatusFalse(form.registerIp)" v-if="form.status==1">
                    禁用
                  </button>
                </div>
                <div style="width: 100%;height: 65px;text-align: left;font-size: 18px">
                  <span style="margin-left: 20px;margin-top: 20px">登录密码：  {{form.loginPasswordStatus==1 ? '已设置' : '未设置'}}</span>
                  <button @click="resetPassword(form.id)" style="margin-left: 50px">
                    重置
                  </button>
                </div>
                <div style="width: 100%;height: 65px;text-align: left;font-size: 18px">
                  <span style="margin-left: 20px;margin-top: 20px">支付密码：  {{form.payPasswordStatus==1 ? '已设置' : '未设置'}}</span>
                  <button @click="sernullPayPassword(form.id)" style="margin-left: 50px"  >
                    置空
                  </button>

                </div>
              </div>
            </div>
          </div>
<!--          下半部分-->
          <div style="background-color: whitesmoke;width: 1880px;height: 100%" >
            <el-tabs v-model="activeName" @tab-click="handleClick" style="margin-left: 30px">
              <el-tab-pane label="基本信息" name="first">
              <div style="text-align: left;margin-top: 30px">
                <div style="width: 300px;height: 60px;font-size: 20px;">
                 <span style="margin-left: 30px"> ID: {{form.id}}</span>
                </div>
                <div style="width: 300px;height: 60px;font-size: 20px;">
                  <span style="margin-left: 30px"> 真实姓名: {{form.name}}</span>
                </div>
                <div style="width: 300px;height: 60px;font-size: 20px;">
                  <span style="margin-left: 30px"> 手机号码: {{form.phone}}</span>
                </div>
                <div style="width: 300px;height: 60px;font-size: 20px;">
                  <span style="margin-left: 30px"> 会员状态: {{form.status==1 ? '正常' : '禁用'}}</span>
                </div>
                <div style="width: 300px;height: 60px;font-size: 20px;">
                  <span style="margin-left: 30px"> 注册类型: {{form.registrationType==1 ? '自主注册' : '后台创建'}}</span>
                </div>
                <div style="width: 300px;height: 60px;font-size: 20px;">
                  <span style="margin-left: 30px"> 登录密码: {{form.loginPasswordStatus==1 ? '已设置' : '未设置'}}</span>
                </div>
                <div style="width: 350px;height: 60px;font-size: 20px;">
                  <span style="margin-left: 30px"> 创建日期:   {{form.createDate|format('yyyy-MM-dd hh:mm:ss')}}</span>
                </div>
                <div style="width: 350px;height: 60px;font-size: 20px;">
                  <span style="margin-left: 30px"> 最近登录日期: {{form.loginDate|format('yyyy-MM-dd hh:mm:ss')}}</span>
                </div>

              </div>
              </el-tab-pane>
              <el-tab-pane label="快递员认证" name="second" v-if="form.isVip==1">
                <div style="text-align: left;margin-top: 30px">
                  <div style="width: 300px;height: 60px;font-size: 20px;">
                    <span style="margin-left: 30px"> 认证状态: {{form.expressAuthStatus==1 ? '已认证' :form.expressAuthStatus==2 ?'未认证':'已拒绝'}}</span>
                  </div>
                  <div style="width: 300px;height: 60px;font-size: 20px;">
                    <span style="margin-left: 30px"> 快递公司: {{form.postCompany}}</span>
                  </div>
                  <div style="width: 600px;height: 300px;font-size: 20px;margin-top: 20px">
                    <el-image
                        style="width: 600px; height: 300px"
                        :src="form.workCardImage"
                        :fit="fit"></el-image>
                  </div>
                    工牌或名片照片
                </div>
              </el-tab-pane>
              <el-tab-pane label="实名认证" name="third">
                <div style="text-align: left;margin-top: 30px">
                  <div style="width: 300px;height: 60px;font-size: 20px;">
                    <span style="margin-left: 30px"> 认证状态: {{form.realNameStatus==1 ? '已认证' : form.realNameStatus==1 ? '未认证':'已拒绝'}}</span>
                  </div>
                  <div style="width: 300px;height: 60px;font-size: 20px;">
                    <span style="margin-left: 30px"> 证件类型: {{form.certificateType==1 ? '身份证' : '护照'}}</span>
                  </div>
                  <div style="width: 600px;height: 250px;font-size: 20px;margin-top: 20px">
                    <el-image
                        style="width: 600px; height: 250px"
                        :src="form.certificateImage"
                        :fit="fit"></el-image>
                  </div>
                  证件正面
                  <div style="width: 600px;height: 250px;font-size: 20px;margin-top: 20px">
                    <el-image
                        style="width: 600px; height: 250px"
                        :src="form.certificateHandImage"
                        :fit="fit"></el-image>
                  </div>
                  手持证件正面照
                </div>
              </el-tab-pane>
              <el-tab-pane label="银行卡信息" name="fourth">
                <div style="text-align: left;margin-top: 30px">
                  <div style="width: 300px;height: 60px;font-size: 20px;">
                    <span style="margin-left: 30px"> 绑定状态: {{form.accountStatus==1 ? '已绑定' : '未绑定'}}</span>
                  </div>
                  <div style="width: 300px;height: 60px;font-size: 20px;">
                    <span style="margin-left: 30px"> 国家: {{form.country}}</span>
                  </div>
                  <div style="width: 300px;height: 60px;font-size: 20px;">
                    <span style="margin-left: 30px"> 开户银行: {{form.bank}}</span>
                  </div>
                  <div style="width: 300px;height: 60px;font-size: 20px;">
                    <span style="margin-left: 30px"> 银行卡号: {{form.bankCardNum}}</span>
                  </div>
                  <div style="width: 300px;height: 60px;font-size: 20px;">
                    <span style="margin-left: 30px"> 开户人: {{form.accountPeople}}</span>
                  </div>
                  <div style="width: 350px;height: 60px;font-size: 20px;">
                    <span style="margin-left: 30px"> 绑定时间: {{form.bindingDate|format('yyyy-MM-dd hh:mm:ss')}}</span>
                  </div>
                </div>
              </el-tab-pane>
              <el-tab-pane label="账户信息" name="fifth">
                <div style="text-align: left;margin-top: 30px">
                  <div style="width: 300px;height: 60px;font-size: 20px;">
                    <span style="margin-left: 30px"> 会员余额: {{form.accountBalance}}</span>
                  </div>
                  <div style="width: 300px;height: 60px;font-size: 20px;">
                    <span style="margin-left: 30px"> 支付密码: {{form.payPasswordStatus==1 ? '已设置' : '未设置'}}</span>
                  </div>
                  <div style="width: 300px;height: 60px;font-size: 20px;">
                    <span style="margin-left: 30px"> 账户状态: {{form.accountStatus==1 ? '正常' : '冻结'}}</span>
                    <button style="margin-left: 50px" @click="updateAccountStatusTrue(form.registerIp)"  v-if="form.accountStatus==2">
                      恢复
                  </button>
                    <button style="margin-left: 50px" @click="updateAccountStatusFalse(form.registerIp)" v-if="form.accountStatus==1">
                      冻结
                    </button>
                  </div>
                </div>
              </el-tab-pane>
            </el-tabs>


          </div>
        </div>
      </div>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
// import {listExpressList} from "@/api/expressList/expressList";
import axios from "axios";
export default {
  data() {
    return {
      form: {},
      activeName: 'first',
      phone:null,

    };
  },


  created() {
    this.phone=this.$route.query.phone;
    this.id=this.$route.query.id;
    this.getDetial();
    this.getDetialPhone();
  },


  methods: {
    // 状态变更
    updateStatusFalse(id){
      axios.put("http://localhost:10020/expressList/updateStatusFalse?id="+id).then(response =>{
        this.form = response.data;
        this.getDetial();
        this.getDetialPhone();
      })
    },
    // 状态变更
    updateStatusTrue(id){
      axios.put("http://localhost:10020/expressList/updateStatusTrue?id="+id).then(response =>{
        this.form = response.data;
        this.getDetial();
        this.getDetialPhone();
      });
    },
    // 密码重置为123456
    resetPassword(id){
      this.$confirm('此操作将重置该密码, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        axios.put("http://localhost:10020/expressList/resetPassword?id="+id).then(response =>{
          this.form = response.data;
          this.getDetial();
          this.getDetialPhone();
        });
        this.$message({
          type: 'success',
          message: '重置成功!默认密码为123456'
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消重置'
        });
      });

    },
    goToMachine(){
      this.$router.push(
          {path: "/machineHome"}
      )
    },
    // 置空支付密码
    sernullPayPassword(id){
      this.$confirm('此操作将置空该密码, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        axios.put("http://localhost:10020/expressList/sernullPayPassword?id="+id).then(response =>{
          this.form = response.data;
          this.getDetial();
          this.getDetialPhone();
        });
        this.$message({
          type: 'success',
          message: '已置空，请前往设置支付密码'
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消置空'
        });
      });

    },
    // 账户状态解冻
    updateAccountStatusTrue(id){
      this.$confirm('此操作将置解冻账户状态, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        axios.put("http://localhost:10020/expressList/updateAccountStatusTrue?id="+id).then(response =>{
          this.form = response.data;
          this.getDetial();
          this.getDetialPhone();
        });
        this.$message({
          type: 'success',
          message: '已解冻'
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消'
        });
      });
    },
    // 账户状态冻结
    updateAccountStatusFalse(id){
      this.$confirm('此操作将置冻结账户状态, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        axios.put("http://localhost:10020/expressList/updateAccountStatusFalse?id="+id).then(response =>{
          this.form = response.data;
          this.getDetial();
          this.getDetialPhone();
        });
        this.$message({
          type: 'success',
          message: '已冻结'
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消'
        });
      });
    },
    handleClick(tab, event) {
      console.log(tab, event);
    },
    // 页面跳转
    xitong(){
      this.$router.push(
          {path: "/OutSystems"}
      )
    },
    tiaozhuan(){
      this.$router.push({
        path:'/zhanghuPage'
      })
    },
    baoguo(){
      this.$router.push(
          {path: "/OutPackage"}
      )
    },
    notice() {
      this.$router.push(
          {path: "/HomePage"}
      )
    },
    //跳转其他页面
    other() {
      this.$router.push(
          {path: "/otherView"}
      )
    },
    shouye(){
      this.$router.push(
          {path: "/"}
      )
    },
    // 页面跳转
    expressList(){
      this.$router.push(
          {path: "/expressList"}
      )
    },
    // 页面跳转
    expressAuth(){
      this.$router.push(
          {path: "/expressAuth"}
      )
    },
    expressMember(){
      this.$router.push(
          {path: "/expressMember"}
      )
    },
    // 获取详情信息id
    getDetial(){
      axios.get("http://localhost:10020/expressList/getDetialList?id="+this.id).then(response =>{
        this.form = response.data;
        // 加载状态结束
        this.loading = false;
      });
    },

    // 获取详情信息phone
    getDetialPhone(){
      axios.get("http://localhost:10020/expressList/getDetialListPhone?phone="+this.phone).then(response =>{
        this.form = response.data;
        // 加载状态结束
        this.loading = false;
      });
    },


  },
  filters:{
    format(value,arg){
      function dateFormat(date, format) {
        if (typeof date === "string") {
          var mts = date.match(/(\/Date\((\d+)\)\/)/);
          if (mts && mts.length >= 3) {
            date = parseInt(mts[2]);
          }
        }
        date = new Date(date);
        if (!date || date.toUTCString() == "Invalid Date") {
          return "";
        }
        var map = {
          "M": date.getMonth() + 1, //月份
          "d": date.getDate(), //日
          "h": date.getHours(), //小时
          "m": date.getMinutes(), //分
          "s": date.getSeconds(), //秒
          "q": Math.floor((date.getMonth() + 3) / 3), //季度
          "S": date.getMilliseconds() //毫秒
        };
        format = format.replace(/([yMdhmsqS])+/g, function (all, t) {
          var v = map[t];
          if (v !== undefined) {
            if (all.length > 1) {
              v = '0' + v;
              v = v.substr(v.length - 2);
            }
            return v;
          } else if (t === 'y') {
            return (date.getFullYear() + '').substr(4 - all.length);
          }
          return all;
        });
        return format;
      }

      return dateFormat(value,arg);

    }
  },
};
</script>

<style lang="less">
#app {
  margin-top: 0;
}

.home-container {
  height: 100%;
}

.el-header {
  background-color: #545c64;
  display: flex; //设置显示为flex布局
  justify-content: space-between; //设置为flex左右布局
  padding-left: 0; //左内边距为0（Logo贴左边）
  align-items: center; //元素上下居中（防止右边按钮贴上下边）
  color: #fff;
  font-size: 18px;

  > div {
    //内嵌的div样式
    display: flex;
    align-items: center; //Logo和文字上下居中
    #fontLogo {
      width: 200px;
      margin-left: 10px; //文字左侧设置间距，防止与Logo紧贴
    }
    #fontName {
      width: 120px;
      margin-right: 10px;
    }
  }
}

#indexMenu {
  width: 100%;
}

.el-menu {
  background-color: #545c64;
}

.el-aside {
  background-color: #545c64;
  scrollbar-width: none; /* firefox */
  -ms-overflow-style: none; /* IE 10+ */
  overflow-x: hidden;
  overflow-y: auto;
}

.el-main {
  background-color: #eaedf1;
  height: 1000px;
}
</style>

